#!/usr/bin/env python
# coding:utf-8
# @author heitfei

"""
SocketServer
默认处理完就自动关闭客户端到链接，所以客户端多次链接需要对此建立socket链接
"""

from SocketServer import TCPServer as TCP
from SocketServer import StreamRequestHandler as SRH
import time

HOST = ''
PORT = 23567
ADDR = (HOST, PORT)

class MyRequestHandler(SRH):
    def handle(self):
        print '... connected from:', self.client_address
        self.wfile.write('[%s] %s' % (time.ctime(), self.rfile.readline()))

tcpServ = TCP(ADDR, MyRequestHandler)
print 'waiting for connect...'
tcpServ.serve_forever()
